<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MktPostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '贴子';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mkt-post-index">

    <h1 style="display:none;"><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('创建', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php //Pjax::begin(); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
			[
				'label' => 'ID',
                'attribute' => 'id',
                'filter' => false,
                'headerOptions' => array('style'=>'width:40px;'), 
                'visible' => false,
			],

            //'user_id',
            'user.name',

            [
                'attribute' => 'post_type',
                'value'=>function ($model, $key, $index, $column) { 
                    return common\models\MktPost::getPostTypeOption($model->post_type); 
                },
                'filter'=> common\models\MktPost::getPostTypeOption(),
            ],

            
            'title',
            
            'content:ntext',

            // 'start_time',
            // 'end_time',
            // 'industry_id',
            // 'area_id',
            // 'status',

            [
                'attribute' => 'status',
                'value'=>function ($model, $key, $index, $column) { 
                    return common\models\MktPost::getPostStatusOption($model->status); 
                },
                'filter'=> common\models\MktPost::getPostStatusOption(),
            ],

            [
                'label' => '回贴',
                'format'=>'html',
                'value'=>function ($model, $key, $index, $column) { 
                    //if (empty($model->postResponseCount)) return '0';
				    return Html::a($model->postResponseCount, ['post-response/index', 'post_id'=>$model->id]);
                },
            ],

            // 'is_anoymous',
            // 'create_time',
            // 'update_time',
            // 'cooperation_reward:ntext',
            // 'job_salary_min',
            // 'job_salary_max',
            // 'job_education',
            // 'job_experience',
            // 'job_age_min',
            // 'job_age_max',

//            ['class' => 'yii\grid\ActionColumn'],
               [
                    'class' => 'yii\grid\ActionColumn',
                    'template' => '{delete} {update}',
               ],
        ],
    ]); ?>

    <?php //Pjax::end(); ?>
</div>
